/**
 * @name v-input-selection 输入框内容自动选中
 */

export default {
  mounted(el) {
    const input = el.tagName === 'INPUT' ? el : el.querySelector('input')
    input?.addEventListener('focus', () => {
      setTimeout(() => input.setSelectionRange(0, input.value?.length), 10)
    })
    input?.addEventListener('blur', () => input.setSelectionRange(0, 0))
  }
}
